package com.autohammal.ui.frame.data;

import org.eclipse.swt.widgets.Composite;

public class ItemsCompositeViewer extends AbstractViewer {

	public enum ItemView {
		CONFIG, INPUT, OUTPUT
	}

	public ItemsCompositeViewer() {
	}

	public ItemsCompositeViewer(ViewData originView) {
		super(originView);
	}

	public ItemsCompositeViewer(ViewData originView, ViewData masterView) {
		super(originView, masterView);
	}

	public void setItemsView(final ItemView itemView, final Composite composite) {
		ViewData viewData = new ViewData() {

			@Override
			public Viewer getViewer() {
				return ItemsCompositeViewer.this;
			}

			@Override
			public String getName() {
				return itemView.toString();
			}

			@Override
			public Object getData() {
				return composite;
			}
		};
		addView(viewData);
	}

	public ViewData getItemView(final ItemView itemView) {
		return getView(itemView.toString());
	}

	public Composite getItemViewValue(final ItemView itemView) {
		ViewData viewData = getView(itemView.toString());
		if (viewData != null && viewData.getData() instanceof Composite)
			return (Composite) viewData.getData();
		return null;
	}
}
